Update GUI of DXL Script

Hi,

I'm fairly new to DXL, but have got to a stage where I think I have the basic operations I need going. One part that I'm particularly stuck on is updating the gui from the DXL script.

 

I have 4 drop-down choice menus and based on the item selected in the choice, I would like to have a label beside the choice that shows the number of items in that selected filter. The second choice is affected by both the first and the second choice menu. Searching around, it seems to suggest that this is not possible, and the only solution I have found is to have several labels which I hide/unhide based on the choices.

 

Is this the best solution?


DataHoarder - Fri Mar 23 06:46:30 EDT 2018

Re: Update GUI of DXL Script
PekkaMakinen - Fri Mar 23 07:20:40 EDT 2018

Have you tried to do callbacks? If I understand you correctly you could have callbacks which collect the data from the choices and display it is one label. See example below.

 

DB TestDB = null
DBE FirstDB = null
DBE SecondDB = null
DBE ResultLabel = null

string FirstSelections[] = {"First1", "First2", "First3", "First4"}
string SecondSelections[] = {"Second1", "Second2", "Second3", "Second4"}


void FirstDB_CB (DBE dbe)
{
   string first = get FirstDB
   string second = get SecondDB
   set (ResultLabel, "Selections are " first "/" second "")
}

void SecondDB_CB (DBE dbe)
{
   string first = get FirstDB
   string second = get SecondDB
   set (ResultLabel, "Selections are " first "/" second "")
}

//Main

TestDB = create("Test")
FirstDB = choice(TestDB, "First choice", FirstSelections, 0)
beside TestDB
SecondDB = choice(TestDB, "Second choice", SecondSelections, 0)
left TestDB
ResultLabel = label(TestDB, "Selections are " FirstSelections[0] "/" SecondSelections[0] "")

// Set callbacks for the choice DBEs
set(FirstDB, FirstDB_CB)
set(SecondDB, SecondDB_CB)

// Show the dialog
show TestDB

Re: Update GUI of DXL Script
DataHoarder - Fri Mar 23 10:58:16 EDT 2018

Hi,

 

Thanks for your assistance with that, this works quite well. My only issue is that when the choice changes, it seems to lag. So when I change the choice in the selection, it carries out the callback based on the original choice, rather than what I have changed it to. When I then make a new selection, it updates to the second value, instead of the third.

 

Any ideas on where this lag is occurring?

Re: Update GUI of DXL Script
davidcs - Fri Mar 23 11:36:49 EDT 2018

Jeez, I have had this issue before. I thought it has to do how you declare the choice DB. If you are using some of the optional parameters, strip them out and declare it just as Pekka Makinen did. If that works, then you can go back and figure out which parameter is causing the problem.

 

Re: Update GUI of DXL Script
PekkaMakinen - Mon Mar 26 00:58:55 EDT 2018

davidcs - Fri Mar 23 11:36:49 EDT 2018

Jeez, I have had this issue before. I thought it has to do how you declare the choice DB. If you are using some of the optional parameters, strip them out and declare it just as Pekka Makinen did. If that works, then you can go back and figure out which parameter is causing the problem.

 

Yes, if I modify my example so that the choice is editable:

FirstDB = choice(TestDB, "First choice", FirstSelections, 0,10,true)

then the callback function does not update the label with the selected value on selection, only on the next selection.

 

Re: Update GUI of DXL Script
DataHoarder - Mon Mar 26 05:15:44 EDT 2018

Thank you so much for all your help. On consideration, I've created an update buttons so that the choice boxes can be manipulated and then the stats updated. This is a better solution for my system as if it were to update after each choice box change there would be a pause as the stat is calculated.

 

But I do have the "true" on the end of my choice, so I agree that must be the cause.